<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <include file="Public:header" />
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerToolBar.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
    <script src="__PUBLIC__/lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
    <script type="text/javascript">

    	var grid,mydialog;
    	var groupicon = "__PUBLIC__/lib/ligerUI/skins/icons/communication.gif";
    	var favoritelist=<php>echo json_encode($favorite);</php>;
    	$(function ()
        {
        	
        	grid =$("#maingrid").ligerGrid({
                columns: [
                { display: '菜单', name: 'title', align: 'left', width: 200, minWidth: 60 },
                { display: '名称', name: 'name', align: 'left', width: 100, minWidth: 60 },
                { display: '图标', name: 'nodeicon', align: 'left', width: 100, minWidth: 60,render: function (rowdata, rowindex, value){if(value){return '<IMG SRC="__ROOT__/'+value+'" WIDTH="20" HEIGHT="20" BORDER="0"/>';}}}
                // { display: '创建日期', name: 'create_time', minWidth: 140,type: 'date',render:function (rowdata, rowindex, value){return DateFormat(value,"yyyy-MM-dd ");} },
               // { display: '上次登录', name: 'last_login_time',type: 'date',render:function (rowdata, rowindex, value){return DateFormat(value,"yyyy-MM-dd hh:mm:ss");} },
              //  { display: '登录次数', name: 'login_count' },
              //  { display: '状态', name: 'status',render:function (row){return (row.status ==true)?'<img src="__PUBLIC__/lib/ligerui/skins/icons/ok.gif">':'<img src="__PUBLIC__/lib/ligerui/skins/icons/lock.gif">';} }
                ], 
                url:'__URL__/getNodeData/',  pageSize:30 ,rownumbers:true,height:'100%',checkbox:true,isChecked: f_isChecked,
                toolbar: { items: [
                { text: '保存', click: f_save,img: "__PUBLIC__/lib/icons/silkicons/page_save.png" },
                { line: true },
                { text: '排序', click: f_sort, icon: 'modify' },
                { line: true },
                { text: '排序', click: f_del, icon: 'modify' },
                
                ]
                }
            });
            $("#pageloading").hide();
        });
        
          
        function getSelectedIds()
        {
        	var rows=grid.getCheckedRows();
        	var checkid=[];
        	 for(var i =0;i<rows.length;i++)
             {
        		 
        		 checkid.push(rows[i].id);   
             }
        	 return (checkid.join(','));

        }
        function f_del()
        {
        	$.get('__URL__/getNodeData',function(data){
        		alert(data);
        	});
        }
        
        function f_save()
        {
        	checkid=getSelectedIds();
        	$.post("__URL__/saveFavorite/",{"favoriteList":checkid}, function(data){
             	LG.tip($.parseJSON(data).info);
              });
        }
        function f_sort()
        {
        	checkid=getSelectedIds();
        	//var rows=grid.getCheckedRows();
        	mydialog=$.ligerDialog.open({ url: '__URL__/sort/sortId/'+checkid, height: 500, width: 400,
            //  	buttons: [{ text: '确定', onclick: function (item, dialog) {save(dialog); } },
            //                { text: '取消', onclick: function (item, dialog) { dialog.close(); } }],
                            isResize: true,isHidden:false
           });
        	
        }
        
        function f_isChecked(rowdata)
        {
           if(!favoritelist)return;
            for (var i = 0, l = favoritelist.length; i < l; i++)
            {
            	if(favoritelist[i].node_id==rowdata.id)return true;
            }
            return false;
           
        }

    </script>
</head>

<body style="overflow-x:hidden; padding:2px;">
<div class="l-loading" style="display:block" id="pageloading"></div>
 <div class="l-clear"></div>
    <div id="maingrid"></div>
  <div style="display:none;">
</div>
 
</body>
</html>
